package edu.xpu.project.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import edu.xpu.project.user.entity.StudentClass;
import edu.xpu.project.user.service.StudentClassService;

/**
 * @ClassName: ClassController.java
 * @Description: TODO
 *
 * @author liukang
 * @date 2017年5月22日 下午1:50:12
 * @version 
 * @since JDK 1.6
 */
@Controller
@RequestMapping(value="class")
public class ClassController {
	
	@Autowired
	private StudentClassService classService;
	
	/**
	  * @MethodName: classList
	  * @Description: 班级list
	  * @param pageNumber
	  * @param pageSize
	  * @param studentClass
	  * @param modelMap
	  * @return String    返回类型
	  * @Author liukang
	  * @date 2017年5月22日  下午1:52:57
	 */
	@RequestMapping(value="classList")
	public String classList(@RequestParam(value="pageNumber", defaultValue="1", required=false) String pageNumber,
			@RequestParam(value="pageSize", defaultValue="10", required=false) String pageSize,
			StudentClass studentClass, ModelMap modelMap) {
		Page<StudentClass> pageByCriterias = classService.getPageByCriterias(pageNumber, pageSize, studentClass);
		//将各个参数传到前端
		modelMap.addAttribute("page", pageByCriterias)
				.addAttribute("searchVal", studentClass)
				.addAttribute("number", pageNumber)
				.addAttribute("size", pageSize);
		return "stuAttachPage/classList";
	}

}

